package com.solar.etl.transform;

import java.util.Iterator;

import org.dom4j.Element;

import com.solar.etl.config.EtlConfig;
import com.solar.etl.config.mapping.Field;
import com.solar.etl.spi.Itransform;

public class EqualsXml implements Itransform{

	@Override
	public String transform(Field field, Element operate) {
		String value=field.destValue;
		if(null==value){value="";}
		Iterator<Element> operateiteror =operate.elementIterator();
		 while(operateiteror.hasNext()){
			 Element item = (Element) operateiteror.next();
			 String text=item.getTextTrim();
			 if(null==text){value="";}
			 if(item.getName().equals("if")){
				String att=item.attributeValue("value");
				if(att.equals(value)){
					 field.destValue=text;
					 break;
				 }
			 }else{
				 if(!"".equals(text)){
					 if("null".equals(text)){
						 field.destValue="";
					 }
					 field.destValue=text;
				 }
			 }
		 }
		return null;
	}

}
